<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
   
    <ui:composition template="/views/_template.xhtml">
        <ui:define name="corpo">
            <div >
                <h4>
                    <h:outputLabel style="text-align: right; margin-left: 720px; color: #99a699;" value="Total de registro: #{bancoBean.contRegistro}" />
                </h4>
                <h:outputLabel value="Consulta dos clientes cadastrados" style="border-bottom: 3px solid #C22; text-align: left; font-size: 18px; width: 900px; margin-bottom: 15px;" />    
            </div>
                <h:form >
                    <h:panelGrid style="border: 1px solid #999999;  background-color: #E4E4E4; width: 900px;">
                        <h:column>
                            <h:outputLabel value="Tipo de pessoa:" for="pessoa" style=""/>
                            <p:selectOneMenu value="#{clienteBean.tipoPessoa}" immediate="true">
                                <f:selectItem itemLabel="Selecione um tipo de pessoa" itemValue="" />
                                <f:selectItem itemLabel="Pessoa Júridica" itemValue="JURIDICA" />
                                <f:selectItem itemLabel="Pessoa Fisica" itemValue="FISICA" />
                            </p:selectOneMenu>
                        </h:column>
                        <h:column>
                            <h:commandButton value="OK" action="#{clienteBean.tipoPessoaChanged()}" />
                        </h:column>
                    </h:panelGrid>
                </h:form>
                <h:form >                       
                    <p:dataTable value="#{clientePFBean.clientesPF}" var="clientePF" emptyMessage="Nenhum registro encontrado!" >
                        <p:column style="width: 10px; text-align: left" headerText="ID">
                            <h:outputText value="#{clientePF.id}" />
                        </p:column>
                        <p:column style="width: 750px; text-align: left;" headerText="Nome do cliente" sortBy="#{clientePF.nome}" >
                            <h:outputText  value="#{clientePF.nome}"/>
                        </p:column>
                        <p:column style="width: 300px; text-align: left;" headerText="CPF" >
                            <h:outputText value="#{clientePF.cpf}" />
                        </p:column>
                        <p:column style="width: 10px;" headerText="Visualizar dados">
                            <center>
                                <h:commandLink rendered="#{clientePJ.id == clientePJBean.clientePJ.id}" action="visualizarClientePJ">
                                    <h:graphicImage library="imagens" name="ico.visualizar.gif" style="width: 30px; height: 20px;" />
                                </h:commandLink>
                            </center>
                        </p:column>
                        <p:column style="width: 10px;" headerText="Alterar">
                            <center>
                                <h:commandLink action="#{clientePFBean.alterar(clientePF)}">
                                    <h:graphicImage library="imagens" name="edit-icon.gif" style="width: 30px; height: 20px;" />
                                </h:commandLink>
                            </center>
                        </p:column>
                        <p:column style="width: 10px;" headerText="Excluir">
                            <center>
                                <h:commandLink action="#{clientePFBean.remover(clientePF)}">
                                    <h:graphicImage library="imagens" name="icon_delete.gif" style="width: 30px; height: 20px;" />
                                </h:commandLink>

                            </center>
                        </p:column>
                     </p:dataTable><br />
                    <h:commandButton value="Novo" action="incluirClientePF" />
                    <h:commandButton value="Voltar" action="index" immediate="true"/>

                </h:form>
        </ui:define>
    </ui:composition>
</html>

